---
import "#/styles/fonts.css"

import { getFileContent } from "#/lib/node-utilities.ts"
import { Code } from "@astrojs/starlight/components"

type CodeProps = Parameters<typeof Code>[0]

interface Props extends Omit<CodeProps, "code" | "lang"> {
  filepath: string
  filename: string
  language: CodeProps["lang"]
}

const { filepath, filename, title, language, ...remainingProps } = Astro.props

const fileContent = await getFileContent({ filepath })
---

<Code
  lang={language}
  code={fileContent}
  title={filename || title}
  class:list={["expressive-code"]}
  {...remainingProps}
/>
